package kr.hyunist.androidcomplete02saeildamil.ch26;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class ProductDBHelper extends SQLiteOpenHelper {
	
	public ProductDBHelper(Context context) {
		super(context, "product.db", null, 1);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("create table product (_id integer primary key autoincrement, name text, price integer);");
		db.execSQL("insert into product values(null, '오징어땅콩', 1000);");
		db.execSQL("insert into product values(null, '허니버터침', 1500);");
		db.execSQL("insert into product values(null, '새우깡', 1000);");
		db.execSQL("insert into product values(null, '포카칩', 2000);");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL("drop table if exists product");
		onCreate(db);
	}

}
